<template>
  <div class="box1">
    <h1>我是子组件Event2</h1>
    <p @click="handler">点击我触发自定义事件</p>
    <button @click="chufa()">自定义事件2</button>
    <button @click="$emit('click', 'ak47')">自定义事件click</button>
  </div>
</template>

<script setup lang="ts">
//利用defineEmits方法返回函数触发自定义事件
//defineEmit方法不需要引入直接使用
let $emit = defineEmits(["xxx", "zzz", "click"]);
//console.log($emit, "####");
const handler = () => {
  //第一个参数：事件类型，第二个参数。。。。为注入数据
  $emit("xxx", "火箭", "飞机", "大炮");
};

const chufa = () => {
  $emit("zzz", "努力奋斗");
};
</script>

<style scoped>
.box1 {
  width: 400px;
  height: 200px;
  background: yellowgreen;
}
</style>
